﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	// Token: 0x02000089 RID: 137
	[EditorBrowsable(EditorBrowsableState.Never)]
	public class HDevWindowStack : IDisposable
	{
		// Token: 0x06001E00 RID: 7680 RVA: 0x000B5430 File Offset: 0x000B3630
		~HDevWindowStack()
		{
			try
			{
				this.Dispose(false);
			}
			catch (Exception)
			{
			}
		}

		// Token: 0x06001E01 RID: 7681 RVA: 0x000B546C File Offset: 0x000B366C
		private void Dispose(bool disposing)
		{
			if (disposing)
			{
				GC.SuppressFinalize(this);
			}
			GC.KeepAlive(this);
		}

		// Token: 0x06001E02 RID: 7682 RVA: 0x000B547D File Offset: 0x000B367D
		void IDisposable.Dispose()
		{
			this.Dispose(true);
		}

		/// <summary>Releases the resources used by this tool object</summary>
		// Token: 0x06001E03 RID: 7683 RVA: 0x000B547D File Offset: 0x000B367D
		public virtual void Dispose()
		{
			this.Dispose(true);
		}

		// Token: 0x06001E04 RID: 7684 RVA: 0x000B5488 File Offset: 0x000B3688
		public static void Push(HTuple win_handle)
		{
			int num;
			if (win_handle.Type == HTupleType.HANDLE)
			{
				HHandle h = win_handle.H;
				num = HalconAPI.HWindowStackPush(h.Handle);
				GC.KeepAlive(h);
			}
			else
			{
				num = HalconAPI.HWindowStackPush(win_handle.IP);
			}
			if (num != 2)
			{
				throw new HalconException(num, "HDevWindowStack::Push");
			}
		}

		// Token: 0x06001E05 RID: 7685 RVA: 0x000B54D4 File Offset: 0x000B36D4
		public static HTuple Pop()
		{
			IntPtr intPtr;
			int num = HalconAPI.HWindowStackGetActive(out intPtr);
			if (num != 2)
			{
				throw new HalconException(num, "HDevWindowStack::Pop");
			}
			HTuple result;
			if (HalconAPI.IsLegacyHandleMode())
			{
				result = intPtr;
			}
			else
			{
				using (HHandle hhandle = new HHandle(intPtr))
				{
					result = new HTuple(hhandle);
				}
			}
			num = HalconAPI.HWindowStackPop();
			if (num != 2)
			{
				throw new HalconException(num, "HDevWindowStack::Pop");
			}
			return result;
		}

		// Token: 0x06001E06 RID: 7686 RVA: 0x000B554C File Offset: 0x000B374C
		public static HTuple GetActive()
		{
			IntPtr intPtr;
			int num = HalconAPI.HWindowStackGetActive(out intPtr);
			if (num != 2)
			{
				throw new HalconException(num, "HDevWindowStack::GetActive");
			}
			HTuple result;
			if (HalconAPI.IsLegacyHandleMode())
			{
				result = intPtr;
			}
			else
			{
				using (HHandle hhandle = new HHandle(intPtr))
				{
					result = new HTuple(hhandle);
				}
			}
			return result;
		}

		// Token: 0x06001E07 RID: 7687 RVA: 0x000B55AC File Offset: 0x000B37AC
		public static void SetActive(HTuple win_handle)
		{
			int num;
			if (win_handle.Type == HTupleType.HANDLE)
			{
				HHandle h = win_handle.H;
				num = HalconAPI.HWindowStackSetActive(h.Handle);
				GC.KeepAlive(h);
			}
			else
			{
				num = HalconAPI.HWindowStackSetActive(win_handle.IP);
			}
			if (num != 2)
			{
				throw new HalconException(num, "HDevWindowStack::SetActive");
			}
		}

		// Token: 0x06001E08 RID: 7688 RVA: 0x000B55F8 File Offset: 0x000B37F8
		public static bool IsOpen()
		{
			bool result;
			int num = HalconAPI.HWindowStackIsOpen(out result);
			if (num != 2)
			{
				throw new HalconException(num, "HDevWindowStack::IsOpen");
			}
			return result;
		}

		// Token: 0x06001E09 RID: 7689 RVA: 0x000B5620 File Offset: 0x000B3820
		public static void CloseAll()
		{
			int num = HalconAPI.HWindowStackCloseAll();
			if (num != 2)
			{
				throw new HalconException(num, "HDevWindowStack::CloseAll");
			}
		}
	}
}
